package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbSpecificationMapper;
import com.dongdongshop.mapper.TbSpecificationOptionMapper;
import com.dongdongshop.pojo.TbSpecification;
import com.dongdongshop.pojo.TbSpecificationOption;
import com.dongdongshop.pojo.TbSpecificationOptionExample;
import com.dongdongshop.service.SpeOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class SpeOptionServiceImpl implements SpeOptionService {

    @Autowired
    private TbSpecificationMapper tbSpecificationMapper;
    @Autowired
    private TbSpecificationOptionMapper tbSpecificationOptionMapper;

//    @Override
//    public Map<Object, Object> selectById(Long id) {
//        List<TbSpecification> speList = tbSpecificationMapper.selectByPrimaryKey(id);
//        List<TbSpecificationOption> specificationOptionList = tbSpecificationOptionMapper.selectById(id);
//        Map<Object,Object> map = new HashMap<>();
//        map.put("speList",speList);
//        map.put("specificationOptionList",specificationOptionList);
//        return map;
//    }

    @Override
    public void deleteById(Long id) {

        int i = tbSpecificationMapper.deleteByPrimaryKey(id);

        TbSpecificationOptionExample ts = new TbSpecificationOptionExample();
        TbSpecificationOptionExample.Criteria criteria = ts.createCriteria();
        criteria.andSpecIdEqualTo(id);

        int i1 = tbSpecificationOptionMapper.deleteByExample(ts);
    }

    @Override
    public Map<Object, Object> selectById(Long id) {
        List<TbSpecification> speList = tbSpecificationMapper.selectByPrimaryKey(id);
        List<TbSpecificationOption> specificationOptionList = tbSpecificationOptionMapper.selectById(id);
        Map<Object,Object> map = new HashMap<>();
        map.put("speList",speList);
        map.put("specificationOptionList",specificationOptionList);
        return map;
    }
}




